package com.yanqu.road.server.timer.uniontrade;

import com.yanqu.road.server.manager.union.trade.CrossUnionTradeMgr;
import com.yanqu.road.utils.date.DateHelper;
import com.yanqu.road.utils.executor.GeneralTask;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;


public class CrossUnionTradeTask extends GeneralTask {

    protected Logger logger = LogManager.getLogger(CrossUnionTradeTask.class.getName());

    private long lastUpdateTime = 0L;

    public CrossUnionTradeTask() {

    }

    @Override
    public void doRun() {
        try {
            CrossUnionTradeMgr.checkAllUnionTradeRouteState();
        }catch (Exception e) {
            logger.error("union trade route state check error:", e);
        }

        //启动执行一次
        try {
            if (lastUpdateTime < DateHelper.getTodayZeroTimeStamp()) {
                CrossUnionTradeMgr.resetOneDay();
                lastUpdateTime = DateHelper.getTodayZeroTimeStamp();
            }
        }catch (Exception e) {
            logger.error("union trade route reset error:", e);
        }
    }

}
